package week3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Ex22 {
    public static void main(String[] args) throws IOException {
        BufferedReader content = new BufferedReader(new FileReader("E:\\javaprj\\javaclub\\src\\week3\\p022-names.txt", StandardCharsets.UTF_8));
        String str = content.readLine();
        String[] names = str.split("\",\"");
        names[0] = names[0].replace("\"", "");
        names[names.length-1] = names[names.length-1].replace("\"", "");
        Arrays.sort(names);
        long sumOfLetter;
        long ans = 0;
        for (int i = 0; i < names.length; i++) {
            char[] arr = names[i].toCharArray();
            sumOfLetter = 0;
            for (char c : arr)
                sumOfLetter += c - 'A' + 1;
            ans += sumOfLetter * (i + 1);
        }
        System.out.println(ans);
        long end = System.currentTimeMillis();
    }
}
